#
# @lc app=leetcode.cn id=724 lang=python
#
# [724] 寻找数组的中心下标
#

# @lc code=start
class Solution(object):
    def pivotIndex(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        pre_sum=[0]
        for i in range(len(nums)):
            pre_sum.append(pre_sum[-1]+nums[i])
        for i in range(1,len(pre_sum)):
            if pre_sum[i-1]==pre_sum[-1]-pre_sum[i]:
                return i-1
        return -1
# @lc code=end

